﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using PhuLeDao.Core;
using PhuLeBussinessObject.Response;
using PhuLeBussinessObject.Core;
using PhuLeBooze.Global;
using PhuLeBussinessObject.Core;

namespace PhuLeBooze.Views.Accounts
{
    public partial class Member : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {


                GetListData("Class", new object[] { ddlClass, ddlClassFilter });
                GetListData("MaritalStatus", new object[] { ddlMaritalStatus, ddlMaritalStatusFilter });
                GetListData("Education", new object[] { ddlEducation, ddlEducationFilter });
                GetListData("Job", new object[] { ddlJob, ddlJobFilter });
                GetListData("UserType", new object[] { ddlType, ddlTypeFilter });
                GetListData("Gender", new object[] { ddlGender, ddlGenderFilter });
                GetListData("Province", new object[] { ddlProvince, ddlProvinceFilter });
            }
        }
        protected void GetListData(string functionCode, object[] arrDDL)
        {
            if (arrDDL != null && arrDDL.Length > 0)
            {
                IList<CListData> list = new CCore().GetListData(functionCode);
                string defaultValue = "";
                foreach (CListData data in list)
                {
                    if (data.IsDefault)
                    {
                        defaultValue = data.Value;
                    }
                }
                foreach (object obj in arrDDL)
                {
                    DropDownList ddl = (DropDownList)obj;
                    ddl.DataSource = list;
                    ddl.DataTextField = "Name";
                    ddl.DataValueField = "Value";
                    ddl.DataBind();
                    if (ddl.Attributes["multiple"] == "multiple")
                    {
                        ddl.Items.Insert(0, new ListItem("(all)", ""));
                    }
                    else
                    {
                        /* Set Default Value */
                        ddl.SelectedValue = defaultValue;
                        ddl.SelectedItem.Attributes["Default-Value"] = "1";
                    }
                }
            }



        }
    }
}